﻿using Kingdee.BOS.App.Core.Utils;
using Kingdee.BOS.Core.List.PlugIn;
using Kingdee.BOS.Core.List.PlugIn.Args;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;

namespace Caraya.MFG.BusinessPlugIn
{
    [Description("生产订单列表插件测试"), HotUpdate]
    public class PRD_MO_List : AbstractListPlugIn
    {
        public override void PrepareFilterParameter(FilterArgs e)
        {
            base.PrepareFilterParameter(e);
            var fs = e.FilterString;
            Debug.WriteLine(fs);

            /* 以下代码用于测试，不要删除
             * 汇总相同物料的数量，写到累计数量字段
            EntryEntity entryEntity = base.View.BusinessInfo.GetEntryEntity("FEntity");
            DynamicObjectCollection entityDataObject = base.View.Model.GetEntityDataObject(entryEntity);
            var grouped = entityDataObject.GroupBy(a => a.GetDynamicObjectItemValue("MaterialId", ""))
                             .Select(group => new { FSumName = group.Key, FSumQty = group.Sum(item => (decimal)item["FQty"]) })
                             .ToList();
            foreach (var item in entityDataObject)
            {
                var fname = item["MaterialId"].ToString();
                var sumQty = grouped.Where(t => t.FSumName == fname).FirstOrDefault().FSumQty;
                this.Model.SetValue("累计数量", sumQty, (int)item["Seq"]);
            }
            */
        }

    }
}
